package com.hxzy.demo.Adapter0923;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import com.hxzy.demo.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Yang on 2016/9/23.
 */
public class TestListViewActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test_list_view);

        ListView listView = (ListView) findViewById(R.id.lv);

        List<Map<String,String>> data = new ArrayList<>();
        for (int i = 0;i<20;i++){
            Map<String,String> map = new HashMap<>();
            map.put("name","学生"+i);
            map.put("char","S"+i);
            data.add(map);
        }
        SimpleAdapter simpleAdapter = new SimpleAdapter(this,data,R.layout.item_test_list_view,
                new String[]{"char","name"},
                new int[]{R.id.contact_char,R.id.contact_name});
        listView.setAdapter(simpleAdapter);
    }
}
